package com.example.administrator.fangbook.importlocal;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.example.administrator.fangbook.HtlMvp.activity.BaseMvpActivity;
import com.example.administrator.fangbook.R;
import com.example.administrator.fangbook.base.BaseFragment;
import com.example.administrator.fangbook.importlocal.fragment.ImportLocalCapacityFragment;
import com.example.administrator.fangbook.importlocal.fragment.ImportLocalFileFragment;
import com.example.administrator.fangbook.mvp_presenter.MainPresenter;
import com.example.administrator.fangbook.mvp_view.MainView;

import java.util.ArrayList;

import butterknife.Bind;

public class ImportLocalBookActivity extends BaseMvpActivity<MainView, MainPresenter> implements MainView {

    @Bind(R.id.local_tab_layout)
    TabLayout localTabLayout;
    @Bind(R.id.local_viewPager)
    ViewPager localViewPager;
    private String[] titles = {"智能导书", "本机文件"};
    private ArrayList<BaseFragment> fragments;

    @Override
    protected boolean getIsHideState() {
        return false;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_import_local_book;
    }

    @Override
    public MainPresenter bindMvpPresenter() {
        return new MainPresenter();
    }

    @Override
    public MainView bindMvpView() {
        return this;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        fragments = new ArrayList<>();
        fragments.add(ImportLocalCapacityFragment.getFragment(null));
        fragments.add(ImportLocalFileFragment.getFragment(null));
        localTabLayout.setupWithViewPager(localViewPager);
        localViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }

            @Override
            public BaseFragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }
        });
    }
}
